class OurClass { const auto_ptr<OtherObject> a; const auto_ptr<OtherObject> b; public: OurClass(const OtherObject &aRef, const OtherObject &bRef): a(new OtherObject(aRef)), b(new OtherObject(bRef)) {}; ~OurClass() {}; .... };
Example:
... foo(const FSSpec& fsSpec...) { auto_ptr<LFile> sourceFile(fsSpec); sourceFile->OpenDataFork(fsCurPerm) ... // code that may throw }